import { BaseAvatar } from "./BaseAvatar";
import { SEntityInfo } from "../../../../Message/BroadCast/SEntityInfo";
import { AvatarEvent } from "./AvatarEvent";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { EventName } from "../../mvc/EventName";
import { NetDispatcher } from "../../../mvc/core/NetDispatcher";
import { ServerCommand } from "../../mvc/ServerCommand";
import { RolePlayer } from "../../scene/player/entity/RolePlayer";
import { PlayerEvent } from "../../scene/events/PlayerEvent";
import { Cache } from "../../cache/Cache";
import { Language } from "../../../../extend/language/Language";
import { GameConst } from "../../../component/gconst/GameConst";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { SDrugBagInfo } from "../../../../Message/Game/SDrugBagInfo";
import { EDrug } from "../../../../Message/Public/EDrug";
import { DrugBagItem } from "./DrugBagItem";
import { DataEvent } from "../../events/DataEvent";
import { BaseProgressBar } from "../common/BaseProgressBar";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { MsgManager } from "../../manager/MsgManager";
import { GameMapUtil } from "../../scene/map/GameMapUtil";
import { EEntityFightMode } from "../../../../Message/Public/EEntityFightMode";
import { Game } from "../../Game";
import { EMapInstanceType } from "../../../../Message/Public/EMapInstanceType";
import { SVIPInfo } from "../../../../Message/Game/SVIPInfo";
import { ClockManager } from "../../manager/ClockManager";
import { HighlightManager } from "../../manager/HighlightManager";
import { GuideArrowManager } from "../../manager/GuideArrowManager";
import { LockInfoData } from "../lock/LockInfoData";
import { ELockStatus } from "../../../../Message/Game/ELockStatus";
import { ScreenOperation } from "../../scene/ScreenOperation";
import { AvatarInfo } from "../../resource/info/AvatarInfo";
import { AvatarType } from "../../resource/info/AvatarType";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ParamsConst } from "../../../common/global/ParamsConst";
import { Alert } from "../../../../com/mui/controls/Alert";
import { EffectManager } from "../../manager/EffectManager";
import { GButton } from "../../../../com/mui/controls/GButton";
import { WorldExBuff } from "./WorldExBuff";
import { TotalLoadRewardLogo } from "../totalLoadReward/TotalLoadRewardLogo";
import { SPublicMiniPlayer } from "../../../../Message/Public/SPublicMiniPlayer";
import { PlayerMiniInfo } from "../../model/PlayerMiniInfo";
import { PlayerOpRegister } from "../common/menu/PlayerOpRegister";
import { PlayerOpMenuConst } from "../common/menu/PlayerOpMenuConst";
import { ToolTipsManager } from "../../../../com/mui/manager/ToolTipsManager";
import { BrowerUtil } from "../../../../com/gengine/utils/BrowerUtil";
import { EntityUtil } from "../../scene/layer/utils/EntityUtil";
import { GImageButton } from "../../../../com/mui/controls/GImageButton";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class RoleAvatar
    
    export  class RoleAvatar extends BaseAvatar
    {
        constructor(arg1: SEntityInfo=null)
        {
            super(arg1);
            this.addEventListener(AvatarEvent.ChangeLifeSet, this.onLifeSetHandler);
            this.addEventListener(AvatarEvent.ChangeManaSet, this.onManaSetHandler);
            Dispatcher.addEventListener(EventName.SysSettingSuccess, this.resetSlider);
            Dispatcher.addEventListener(EventName.Guide_LifeBar, this.onGuideLifeBar);
            NetDispatcher.addCmdListener(ServerCommand.Group_CaptainChange, this.onGroupCaptainChange);
            NetDispatcher.addCmdListener(ServerCommand.Group_PlayerInfoChange, this.onGroupCaptainChange);
            NetDispatcher.addCmdListener(ServerCommand.CrossGroup_CaptainChange, this.onGroupCaptainChange);
            NetDispatcher.addCmdListener(ServerCommand.CrossGroup_PlayerInfoChange, this.onGroupCaptainChange);
            NetDispatcher.addCmdListener(ServerCommand.GuildGroup_PlayerChange, this.onGroupCaptainChange);
            NetDispatcher.addCmdListener(ServerCommand.DrugBagInfoUpdate, this.onDrugBagInfoUpdateHandler);
            NetDispatcher.addCmdListener(ServerCommand.VIPInfoUpdateCommand, this.onVIPInfoUpdateCommandHandler);
            RolePlayer.instance.addEventListener(PlayerEvent.RoleLevelUpdate, this.onRoleLevelUpdateHandler);
            RolePlayer.instance.addEventListener(PlayerEvent.FlyChange, this.onFlyChangeHandler);
            NetDispatcher.addCmdListener(ServerCommand.RoleEnergyUpdate, this.updateEnergyBar);
            Dispatcher.addEventListener(EventName.SexAttributeSexChange, this.onSexAttributeSexChangeHandler);
            Dispatcher.addEventListener(EventName.CampChangeSuccess, this.onCampChangeHandler);
            Dispatcher.addEventListener(EventName.CurWorldLevelUpdate, this.onCurWorldLevelUpdate);
            Dispatcher.addEventListener(EventName.ChangeRoleAvatarHeadIcon, this.onChangeRoleAvatarHeadIcon);
            Dispatcher.addEventListener(EventName.ShineTotalLoadRewardLogo, this.onShineTotalLoadRewardLogo);
            Dispatcher.addEventListener(EventName.Scene_Update, this.onSceneUpdate);
            return;
        }

        /* internal  */onEnergyRollOut(arg1: Object /* flash.events.MouseEvent */): void
        {
            labelTip.visible = false;
            return;
        }

        /* internal  */getEnergyTip(): string
        {
            var loc1=null;
            var loc2=Cache.instance.skill.xpSkill;
            if (loc2) 
            {
                loc1 = Language.getString(50053) + Math.floor(this._energy / GameConst.EnergyMax * 100) + "%";
            }
            else 
            {
                loc1 = Language.getString(50054);
            }
            return HTMLUtil.addColor(loc1, GlobalStyle.color6);
        }

        /* internal  */createDrugBagItem(): void
        {
            var loc1=new SDrugBagInfo();
            loc1.type = EDrug._EDrugLifeBag;
            this._lifeDrugBagItem = new DrugBagItem();
            this._lifeDrugBagItem.name = "life";
            this._lifeDrugBagItem.move(230, 30);
            this._lifeDrugBagItem.drugBagData = loc1;
            this.addChild(this._lifeDrugBagItem);
            var loc2=new SDrugBagInfo();
            loc2.type = EDrug._EDrugManaBag;
            this._manaDrugBagItem = new DrugBagItem();
            this._manaDrugBagItem.name = "mana";
            this._manaDrugBagItem.move(230, 50);
            this._manaDrugBagItem.drugBagData = loc2;
            this.addChild(this._manaDrugBagItem);
            this._lifeDrugBagItem.addEventListener(flash.events.MouseEvent.CLICK, this.onDrugItemClickHandler);
            this._manaDrugBagItem.addEventListener(flash.events.MouseEvent.CLICK, this.onDrugItemClickHandler);
            return;
        }

        /* internal  */onCurWorldLevelUpdate(arg1: DataEvent): void
        {
            this._worldExBuff.y = 6;
            if (this._totalLoadReward) 
            {
                this._worldExBuff.x = this._totalLoadReward.x + this._totalLoadReward.width + 10;
            }
            else 
            {
                this._worldExBuff.x = 270;
            }
            if (Cache.instance.role.getWorldExAble()) 
            {
                this._worldExBuff.visible = true;
            }
            else 
            {
                this._worldExBuff.visible = false;
            }
            return;
        }

        /* internal  */createEnergyBar(): void
        {
            this._energyBar = new BaseProgressBar("");
            this._energyBar.isScale = true;
            this._energyBar.progressBarClass = ImagesConst.RoleEnergyBar;
            this._energyBar.setLabelPosition(0, -4);
            this._energyBar.showProgressText = false;
            this._energyBar.setSize(113, 6);
            this._energyBar.move(98, 61);
            this.addChild(this._energyBar);
            this._energyTiptxt = ObjCreate.createGTextField("", 98, 61, 113, 6, this);
            this._energyTiptxt.addEventListener(flash.events.MouseEvent.ROLL_OVER, this.onEnergyRollOver);
            this._energyTiptxt.addEventListener(flash.events.MouseEvent.ROLL_OUT, this.onEnergyRollOut);
            this._energyTiptxt.addEventListener(flash.events.MouseEvent.MOUSE_MOVE, this.onEnergyMouseMove);
            return;
        }

        public /* override */ updateAvatarUI(arg1: SEntityInfo): void
        {
            super.updateAvatarUI(arg1);
            if (this._isInitEnergyBar == false) 
            {
                this.updateEnergyBar();
                this._isInitEnergyBar = true;
            }
            nameLabel.text = Cache.instance.role.entityInfo.name;
            return;
        }

        /* internal  */updateEnergyBar(arg1: Object=null): void
        {
            this._energy = Cache.instance.role.roleInfo.energy;
            this._energyBar.setValue(this._energy, GameConst.EnergyMax);
            if (this._energy == 0) 
            {
                this._isAlertEnergyMax = false;
            }
            if (this._isAlertEnergyMax == false) 
            {
                if (this._energy >= GameConst.EnergyMax) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.RoleEnergyComplete));
                    this._isAlertEnergyMax = true;
                }
            }
            return;
        }

        /* internal  */onDrugBagInfoUpdateHandler(arg1: SDrugBagInfo): void
        {
            if (arg1) 
            {
                if (arg1.type != EDrug._EDrugLifeBag) 
                {
                    if (arg1.type == EDrug._EDrugManaBag) 
                    {
                        if (arg1.remain == 0) 
                        {
                            this._manaDrugBagItem.filters = [FilterConst.colorFilter];
                            Cache.instance.autoResumeSet.isUsingManaDrugBag = false;
                        }
                        else 
                        {
                            this._manaDrugBagItem.filters = [];
                            this._manaDrugBagItem.drugBagData = arg1;
                            Cache.instance.autoResumeSet.isUsingManaDrugBag = true;
                        }
                    }
                }
                else if (arg1.remain == 0) 
                {
                    this._lifeDrugBagItem.filters = [FilterConst.colorFilter];
                    Cache.instance.autoResumeSet.isUsingLifeDrugBag = false;
                }
                else 
                {
                    this._lifeDrugBagItem.filters = [];
                    this._lifeDrugBagItem.drugBagData = arg1;
                    Cache.instance.autoResumeSet.isUsingLifeDrugBag = true;
                }
            }
            return;
        }

        public onModeBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (Cache.instance.arena.isInArenaCopy) 
            {
                MsgManager.showRollTipsMsg(Language.getString(50043));
                return;
            }
            if (GameMapUtil.curMapState.isCrossSpiritWarCopyWaitingRoom || GameMapUtil.curMapState.isCrossSpiritWarCopyCode) 
            {
                MsgManager.showRollTipsMsg(Language.getString(28621));
                return;
            }
            if (Cache.instance.role.entityInfo.fightModel != EEntityFightMode._EEntityFightModePeace) 
            {
                if (Game.sceneInfo.sMapDefine.instanceType.value() == EMapInstanceType._EMapInstanceTypeBattlefield || GameMapUtil.curMapState.isDominionCopy) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(50044));
                    return;
                }
                if (GameMapUtil.isNewBattlefield()) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(41634));
                    return;
                }
                if (Game.sceneInfo.sMapDefine.instanceType.value() == EMapInstanceType._EMapInstanceTypeGuildWar) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(50045));
                    return;
                }
                if (Cache.instance.nationalTrea.nationalInfo.hasCheckIn && Cache.instance.nationalTrea.inActiveScene() && Cache.instance.nationalTrea.nationalInfo.checkInStart) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(27063));
                    return;
                }
                if (!Cache.instance.guild.isInSelfManorMap()) 
                {
                    if (GameMapUtil.isSetFightModeMap(Game.mapInfo.mapId)) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(50046));
                        return;
                    }
                }
                Dispatcher.dispatchEvent(new DataEvent(EventName.FightSetMode, EEntityFightMode.convert(EEntityFightMode._EEntityFightModePeace)));
            }
            else 
            {
                RoleAvatar.alertChangeMode();
            }
            return;
        }

        /* internal  */onVIPInfoUpdateCommandHandler(arg1: SVIPInfo): void
        {
            if (Cache.instance.vip.isVIP) 
            {
                this._vip.styleName = "VIPButton";
                if ((arg1.endDt.time - ClockManager.instance.nowDate.time) / 1000 < 86400) 
                {
                    HighlightManager.instance.glowEffectButton(this._vip, true);
                    this._vip.toolTipData = HTMLUtil.addColor(Language.getString(50055), GlobalStyle.color7);
                }
                else 
                {
                    HighlightManager.instance.glowEffectButton(this._vip, false);
                    this._vip.toolTipData = "";
                }
            }
            else 
            {
                this._vip.styleName = "VipGrayButton";
                this._vip.toolTipData = "";
                HighlightManager.instance.glowEffectButton(this._vip, false);
            }
            return;
        }

        public onVIPLevelUpgrade(arg1: SVIPInfo): void
        {
            HighlightManager.instance.glowEffectButton(this._vip, true);
            var loc1=GuideArrowManager.getGuideArrow(GuideArrowManager.Dir_T);
            loc1.x = this._vip.x + this._vip.width / 2;
            loc1.y = this._vip.y + this._vip.height + 10;
            addChild(loc1);
            return;
        }

        /* internal  */onVipClickHandler(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ShowVIPWindow));
            HighlightManager.instance.glowEffectButton(this._vip, false);
            if (GuideArrowManager.guideArrow.parent == this) 
            {
                GuideArrowManager.hideGuideArrow();
            }
            return;
        }

        /* internal  */onLockBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc2=null;
            var loc1=LockInfoData.lockStatus;
            if (loc1.value() != ELockStatus._ELockStatusLocked) 
            {
                if (loc1.value() != ELockStatus._ELockStatusUnLocked) 
                {
                    if (loc1.value() == ELockStatus._ELockStatusNoPassword || loc1.value() == ELockStatus._ELockStatusNULL) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.LockModuleOpenOrHide));
                    }
                }
                else 
                {
                    loc2 = [];
                    loc2.push(ELockStatus.convert(ELockStatus._ELockStatusLocked), LockInfoData.password);
                    Dispatcher.dispatchEvent(new DataEvent(EventName.LockSetLockStatus, loc2));
                }
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.LockSetUnLockOpen));
            }
            return;
        }

        /* internal  */onFlyBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;

            var loc1;
            e = arg1;
            if (RolePlayer.instance.isDoubleRest) 
            {
                ScreenOperation.interruptDoubleRest((): void
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.Role_FlyStart));
                    return;
                })
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.Role_FlyStart));
            }
            return;
        }

        /* internal  */onFlyEndBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.Role_FlyEnd));
            return;
        }

        public updateLockStatus(): void
        {
            if (this._lockBtn == null) 
            {
                return;
            }
            var loc1=LockInfoData.lockStatus;
            if (loc1 && loc1.value() == ELockStatus._ELockStatusLocked) 
            {
                this._lockBtn.width = 15;
                this._lockBtn.styleName = "lockNotOpenButton";
                this._lockBtn.toolTipData = "<font color=\'#b1efff\'>" + Language.getString(50058) + "</font>";
            }
            else if (loc1 && loc1.value() == ELockStatus._ELockStatusUnLocked) 
            {
                this._lockBtn.width = 18;
                this._lockBtn.styleName = "lockOpenButton";
                this._lockBtn.toolTipData = "<font color=\'#b1efff\'>" + Language.getString(50059) + "</font>";
            }
            else if (loc1 && (loc1.value() == ELockStatus._ELockStatusNoPassword || loc1.value() == ELockStatus._ELockStatusNULL)) 
            {
                this._lockBtn.width = 15;
                this._lockBtn.styleName = "lockNotActiveButton";
                this._lockBtn.toolTipData = "<font color=\'#b1efff\'>" + Language.getString(50060) + "</font>";
            }
            if (this._totalLoadReward) 
            {
                this._totalLoadReward.x = this._lockBtn.x + this._lockBtn.width + 10;
            }
            if (this._worldExBuff) 
            {
                this._worldExBuff.x = this._totalLoadReward.x + this._totalLoadReward.width + 10;
            }
            return;
        }

        /* internal  */onRoleLevelUpdateHandler(arg1: Object): void
        {
            if (Cache.instance.role.getWorldExAble()) 
            {
                this._worldExBuff.visible = true;
            }
            else 
            {
                this._worldExBuff.visible = false;
            }
            if (Cache.instance.role.entityInfo.level >= 30) 
            {
                this._lockBtn = ObjCreate.createGButton("", 220, 3, 15, 20, this);
                this._lockBtn.x = this._linkText.x + this._linkText.textWidth + 10;
                this._lockBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onLockBtnClickHandler);
                this.updateLockStatus();
                this._totalLoadReward.x = this._lockBtn.x + this._lockBtn.width + 10;
                this._worldExBuff.x = this._totalLoadReward.x + this._totalLoadReward.width + 10;
            }
            return;
        }

        /* internal  */onDrugItemClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=(arg1.target as DrugBagItem).name;
            if (loc1 != "life") 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.DrugBagWindowOpen, 1));
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.DrugBagWindowOpen, 0));
            }
            return;
        }

        /* internal  */onSexAttributeSexChangeHandler(arg1: DataEvent): void
        {
            avatarName = AvatarInfo.getPlayerAvatarName(entityInfo.camp, entityInfo.sex, AvatarType.BIG, entityInfo.avatarId);
            return;
        }

        /* internal  */onCampChangeHandler(arg1: DataEvent): void
        {
            this.onSexAttributeSexChangeHandler(null);
            this._campPicName = AvatarInfo.getPicNameByCamp(entityInfo.camp);
            this._campBitmap.bitmapData = GlobalClass.getBitmapData(this._campPicName);
            return;
        }

        /* internal  */onSceneUpdate(arg1): void
        {
            this.updateGroupCaptainState();
            return;
        }

        public hideBuffAfterFine(): void
        {
            buffPanel.hideBuffAfterFine();
            return;
        }

        public showBuffAfterFine(): void
        {
            buffPanel.showBuffAfterFine();
            return;
        }

        public static alertChangeMode(arg1: Function=null): void
        {
            var clickFunction: Function=null;
            var gameName: string;
            var content: string;
            var closeAlert: Function;

            var loc1;
            clickFunction = arg1;
            if (Cache.instance.role.entityInfo.level < GameConst.SetFightModeLevel) 
            {
                MsgManager.showRollTipsMsg(Language.getStringByParam(50056, GameConst.SetFightModeLevel));
                return;
            }
            gameName = ParamsConst.instance.gameName;
            content = HTMLUtil.addColor(Language.getStringByParam(50057, gameName), "#ffea00");
            if (clickFunction == null) 
            {
                closeAlert = (arg1: int): void
                {
                    if (arg1 == Alert.OK) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.FightSetMode, EEntityFightMode.convert(EEntityFightMode._EEntityFightModeFight)));
                    }
                    return;
                }
                Alert.show(content, null, Alert.OK | Alert.CANCEL, null, closeAlert);
            }
            else 
            {
                Alert.show(content, null, Alert.OK | Alert.CANCEL, null, clickFunction);
            }
            return;
        }

        /* internal  */onShineTotalLoadRewardLogo(arg1: DataEvent): void
        {
            var loc1=arg1.data as Boolean;
            if (loc1) 
            {
                EffectManager.glowFilterReg(this._totalLoadReward, [FilterConst.guideTipsFilter], 0.6, 10, 5, 0);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this._totalLoadReward);
            }
            return;
        }

        /* internal  */onChangeRoleAvatarHeadIcon(arg1: DataEvent): void
        {
            avatarName = AvatarInfo.getPlayerAvatarName(entityInfo.camp, entityInfo.sex, AvatarType.BIG, Cache.instance.role.avatar);
            return;
        }

        public get minBtn(): GButton
        {
            return this._minBtn;
        }

        public /* override */ init(): void
        {
            this._energy = Cache.instance.role.roleInfo.energy;
            this.isShowHealthText = false;
            this.isShowManaText = false;
            super.init();
            this.createModeBtn();
            if (ParamsConst.isPay) 
            {
                this.createRechargeBtn();
            }
            mainBgName = ImagesConst.RoleAvatarbg;
            createEffects(15, 110, 75);
            createLifeSlider(AvatarEvent.RoleLifeSliderName);
            createManaSlider(AvatarEvent.RoleManaSliderName);
            avatarName = AvatarInfo.getPlayerAvatarName(entityInfo.camp, entityInfo.sex, AvatarType.BIG, entityInfo.avatarId);
            this._campSprite = new Object /* flash.display.Sprite */();
            this._campSprite.x = 5;
            this._campSprite.y = 10;
            this.addChild(this._campSprite);
            this._campPicName = AvatarInfo.getPicNameByCamp(entityInfo.camp);
            this._campBitmap = GlobalClass.getBitmap(this._campPicName);
            this._campBitmap.width = 25;
            this._campBitmap.height = 26;
            this._campSprite.addChild(this._campBitmap);
            this._teamMarkBitmap = GlobalClass.getBitmap(ImagesConst.TeamLeaderH);
            this._teamMarkBitmap.width = 48;
            this._teamMarkBitmap.height = 23;
            this._teamMarkBitmap.x = 10;
            this._teamMarkBitmap.y = 97;
            this._teamMarkBitmap.visible = false;
            this.addChild(this._teamMarkBitmap);
            this._vip = ObjCreate.createGButton("", 45, 3, 48, 19, this, "VipGrayButton");
            this._vip.addEventListener(flash.events.MouseEvent.CLICK, this.onVipClickHandler);
            this._linkText = ObjCreate.createTextField("", 95, 5, 220, 20, this, GlobalStyle.textFormat6);
            this._linkText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            var loc1=ParamsConst.instance.fastUrl;
            if (loc1 && !(loc1 == "")) 
            {
                this._linkText.htmlText = Language.getString(50039);
            }
            else 
            {
                this._linkText.htmlText = Language.getString(50040);
            }
            this._linkText.addEventListener(flash.events.TextEvent.LINK, this.onLinkTextClickHandler);
            if (Cache.instance.role.entityInfo.level >= 30) 
            {
                this._lockBtn = ObjCreate.createGButton("", 220, 3, 15, 20, this);
                this._lockBtn.x = this._linkText.x + this._linkText.textWidth + 10;
                this._lockBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onLockBtnClickHandler);
                this.updateLockStatus();
            }
            this._flyBtn = ObjCreate.createGLoadedButton("WingFlyBtn", 257, 20, 60, 50, this);
            this._flyBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onFlyBtnHandler);
            this._flyEndBtn = ObjCreate.createGLoadedButton("WingFlyEndBtn", 257, 20, 60, 50, this);
            this._flyEndBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onFlyEndBtnHandler);
            this._flyEndBtn.visible = false;
            Dispatcher.addEventListener(EventName.HeaderSliderUp, this.sliderUp);
            this.createOperMenuSprite();
            this.reRegistOperMenu();
            this.registToolTip();
            this.createDrugBagItem();
            this.createEnergyBar();
            this.resetPos();
            this._minBtn = ObjCreate.createGButton("", 90, 96, 13, 13, this, "MinMinusBtn");
            this._minBtn.visible = false;
            this._minBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBuffMinBtnClick);
            this._worldExBuff = new WorldExBuff();
            this.addChild(this._worldExBuff);
            this._worldExBuff.visible = false;
            this._totalLoadReward = new TotalLoadRewardLogo();
            if (this._lockBtn) 
            {
                this._totalLoadReward.x = this._lockBtn.x + this._lockBtn.width + 10;
            }
            else 
            {
                this._totalLoadReward.x = 245;
            }
            this._totalLoadReward.y = 6;
            addChild(this._totalLoadReward);
            this._totalLoadReward.addEventListener(flash.events.MouseEvent.CLICK, this.onTotalLoadRewarClick);
            return;
        }

        protected onTotalLoadRewarClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.OpenTotalLoadModule));
            return;
        }

        protected onBuffMinBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this.buffPanel.isHideAfterFine) 
            {
                this.buffPanel.showBuffAfterFine();
                this._minBtn.styleName = "MinMinusBtn";
            }
            else 
            {
                this.buffPanel.hideBuffAfterFine();
                this._minBtn.styleName = "MinPlusBtn";
            }
            return;
        }

        /* internal  */resetPos(): void
        {
            avatarBg.y = 15;
            avatarBitmap.x = 28;
            avatarBitmap.y = 28;
            nameLabel.y = 23;
            levelLabel.move(48, 72);
            healthBar.setSize(115, 8);
            healthBar.progressBarClass = ImagesConst.Shengmingtiao;
            healthBar.move(97, 43);
            lifeSlider.move(97, 43);
            magicBar.move(97, 52);
            magicBar.setSize(115, 8);
            magicBar.progressBarClass = ImagesConst.Mofatiao;
            manaSlider.move(97, 50);
            return;
        }

        public createOperMenuSprite(): void
        {
            this._operMenuSprite = new Object /* flash.display.Sprite */();
            this._operMenuSprite.buttonMode = true;
            this._operMenuSprite.x = 52;
            this._operMenuSprite.y = 58;
            this._operMenuSprite.graphics.beginFill(16711680, 0);
            this._operMenuSprite.graphics.drawCircle(0, 0, 30);
            this._operMenuSprite.cacheAsBitmap = true;
            this.addChild(this._operMenuSprite);
            return;
        }

        /* internal  */reRegistOperMenu(): void
        {
            var loc2=false;
            var loc3=false;
            if (this._sMiniPlayer == null) 
            {
                this._sMiniPlayer = new SPublicMiniPlayer();
            }
            this._sMiniPlayer.entityId = entityInfo.entityId;
            this._sMiniPlayer.camp = entityInfo.camp;
            this._sMiniPlayer.career = entityInfo.career;
            this._sMiniPlayer.careerEnable = entityInfo.careerEnable;
            this._sMiniPlayer.entityId = entityInfo.entityId;
            this._sMiniPlayer.name = entityInfo.name;
            this._sMiniPlayer.online = 1;
            this._sMiniPlayer.sex = entityInfo.sex;
            this._playerMiniInfo = new PlayerMiniInfo(this._sMiniPlayer);
            var loc1=GameMapUtil.isCrossGroupMap();
            PlayerOpRegister.UnRegister(this._operMenuSprite);
            if (loc1) 
            {
                loc2 = Cache.instance.crossGroup.isInGroup;
                loc3 = Cache.instance.crossGroup.isCaptain;
            }
            else 
            {
                loc2 = Cache.instance.group.isInGroup;
                loc3 = Cache.instance.group.isCaptain;
            }
            if (loc2) 
            {
                if (loc3) 
                {
                    PlayerOpRegister.Register(this._operMenuSprite, this._playerMiniInfo, PlayerOpMenuConst.RoleCaptainOpMenu);
                }
                else 
                {
                    PlayerOpRegister.Register(this._operMenuSprite, this._playerMiniInfo, PlayerOpMenuConst.RoleMemOpMenu);
                }
            }
            else 
            {
                PlayerOpRegister.Register(this._operMenuSprite, this._playerMiniInfo, PlayerOpMenuConst.RoleNoGroupOpMenu);
            }
            return;
        }

        /* internal  */registToolTip(): void
        {
            ToolTipsManager.register(this._campSprite, null, HTMLUtil.addColor(Language.getString(50041), "#FFFFFF"));
            levelLabel.toolTipData = HTMLUtil.addColor(Language.getString(50042), "#FFFFFF");
            return;
        }

        /* internal  */onLinkTextClickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc2=null;
            var loc1=arg1.text;
            var loc3="_blank";
            if (loc1 != "1") 
            {
                if (loc1 != "2") 
                {
                    if (loc1 != "3") 
                    {
                        if (loc1 == "4") 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.GotoPay));
                            return;
                        }
                        if (loc1 == "5") 
                        {
                            loc2 = ParamsConst.instance.fastUrl;
                        }
                    }
                    else 
                    {
                        loc2 = ParamsConst.instance.bbsUrl;
                    }
                }
                else 
                {
                    loc2 = ParamsConst.instance.fastUrl;
                    loc3 = "_self";
                }
            }
            else 
            {
                loc2 = ParamsConst.instance.actimUrl;
            }
            if (loc2) 
            {
                BrowerUtil.getUrl(loc2, loc3);
            }
            return;
        }

        public createRechargeBtn(): void
        {
            return;
        }

        public createModeBtn(): void
        {
            this._modeBtn = new GButton();
            this._modeBtn.label = "";
            this._modeBtn.setSize(27, 27);
            this._modeBtn.x = 10;
            this._modeBtn.y = 68;
            this._modeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onModeBtnClick);
            this.setFightModeButton();
            this.addChild(this._modeBtn);
            return;
        }

        /* internal  */onFlyChangeHandler(arg1: Object): void
        {
            if (RolePlayer.instance.isFlying) 
            {
                this._flyBtn.visible = false;
                this._flyEndBtn.visible = true;
            }
            else 
            {
                this._flyBtn.visible = true;
                this._flyEndBtn.visible = false;
            }
            return;
        }

        public setFightModeButton(): void
        {
            var loc1="";
            if (Cache.instance.role.entityInfo.fightModel != EEntityFightMode._EEntityFightModePeace) 
            {
                if (Cache.instance.role.entityInfo.fightModel == EEntityFightMode._EEntityFightModeFight) 
                {
                    this._modeBtn.styleName = "FightModeButton";
                    loc1 = Language.getString(50049) + HTMLUtil.addColor(Language.getString(50050), "#FF0000") + HTMLUtil.addColor(Language.getString(50051), "#00FF00");
                }
            }
            else 
            {
                this._modeBtn.styleName = "PeaceModeButton";
                loc1 = Language.getString(50047) + HTMLUtil.addColor(Language.getString(50048), "#00FF00");
            }
            this._modeBtn.toolTipData = HTMLUtil.addColor(loc1, "#FFFFFF");
            return;
        }

        /* internal  */onLifeSetHandler(arg1: DataEvent): void
        {
            var loc1=(arg1.data as int) / 100;
            var loc2=manaSlider.value / 100;
            Dispatcher.dispatchEvent(new DataEvent(EventName.HeaderSliderChange, {"id":"role", "lifeSet": loc1, "manaSet": loc2}));
            return;
        }

        /* internal  */onManaSetHandler(arg1: DataEvent): void
        {
            var loc1=lifeSlider.value / 100;
            var loc2=(arg1.data as int) / 100;
            Dispatcher.dispatchEvent(new DataEvent(EventName.HeaderSliderChange, {"id":"role", "lifeSet": loc1, "manaSet": loc2}));
            return;
        }

        /* internal  */sliderUp(arg1: DataEvent): void
        {
            var loc1=arg1.data as string;
            var loc2=this.lifeSlider.value / 100;
            var loc3=this.manaSlider.value / 100;
            if (loc1 != AvatarEvent.RoleLifeSliderName) 
            {
                if (loc1 == AvatarEvent.RoleManaSliderName) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.HeaderSliderChange, {"id":"role", "lifeSet": loc2, "manaSet": loc3}));
                }
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.HeaderSliderChange, {"id":"role", "lifeSet": loc2, "manaSet": loc3}));
            }
            return;
        }

        public resetSlider(arg1: DataEvent): void
        {
            this.manaSlider.value = Cache.instance.autoResumeSet.roleManaSet * 100;
            this.lifeSlider.value = Cache.instance.autoResumeSet.roleLifeSet * 100;
            this.manaSlider.thumbData = getManaSetToolTip(manaSlider.value);
            this.lifeSlider.thumbData = getLifeSetToolTip(lifeSlider.value);
            Dispatcher.dispatchEvent(new DataEvent(EventName.RoleAutoResume));
            return;
        }

        /* internal  */onGuideLifeBar(arg1: DataEvent): void
        {
            lifeSlider.showtips();
            var loc1=GuideArrowManager.getGuideArrow(GuideArrowManager.Dir_L, this.onGuideArrowTimerOut);
            addChild(loc1);
            loc1.x = lifeSlider.getX();
            loc1.y = lifeSlider.y + lifeSlider.height / 2;
            EffectManager.glowFilterReg(lifeSlider, [FilterConst.guideLifeBarFilter], 1, 20, 10, 10);
            return;
        }

        /* internal  */onGuideArrowTimerOut(): void
        {
            lifeSlider.hidetips();
            return;
        }

        /* internal  */onGroupCaptainChange(arg1: Object): void
        {
            this.updateGroupCaptainState();
            return;
        }

        public updateGroupCaptainState(): void
        {
            var loc2=null;
            var loc1=GameMapUtil.isCrossGroupMap();
            if (GameMapUtil.curMapState.isGuildElite) 
            {
                loc2 = Cache.instance.guildElite.captain;
            }
            else if (loc1) 
            {
                loc2 = Cache.instance.crossGroup.captain;
            }
            else 
            {
                loc2 = Cache.instance.group.captain;
            }
            var loc3=Cache.instance.role.entityInfo.entityId;
            if (loc2 && loc3) 
            {
                if (EntityUtil.equal(loc2, loc3)) 
                {
                    this._teamMarkBitmap.visible = true;
                }
                else 
                {
                    this._teamMarkBitmap.visible = false;
                }
            }
            else 
            {
                this._teamMarkBitmap.visible = false;
            }
            this.reRegistOperMenu();
            return;
        }

        protected /* override */ onHealthBarRollOver(arg1: Object /* flash.events.MouseEvent */): void
        {
            super.onHealthBarRollOver(arg1);
            labelTip.data = this.getLifeManaTip();
            return;
        }

        protected /* override */ onManaBarRollOver(arg1: Object /* flash.events.MouseEvent */): void
        {
            super.onManaBarRollOver(arg1);
            labelTip.data = this.getLifeManaTip();
            return;
        }

        /* internal  */getLifeManaTip(): string
        {
            return HTMLUtil.addColor(Language.getString(50037), GlobalStyle.color7) + HTMLUtil.addColor(entityInfo.life + "<font color=\'#ff0000\' size=\'16\'><b> / </b></font>" + entityInfo.maxLife, "#ffffff") + "\n" + HTMLUtil.addColor(Language.getString(50052), GlobalStyle.color4) + HTMLUtil.addColor(entityInfo.mana + "<font color=\'#00a2ff\' size=\'16\'><b> / </b></font>" + entityInfo.maxMana, "#ffffff");
        }

        /* internal  */onEnergyRollOver(arg1: Object /* flash.events.MouseEvent */): void
        {
            labelTip.visible = true;
            labelTip.data = this.getEnergyTip();
            return;
        }

        /* internal  */onEnergyMouseMove(arg1: Object /* flash.events.MouseEvent */): void
        {
            labelTip.x = arg1.stageX + 15;
            labelTip.y = arg1.stageY + 15;
            return;
        }

        protected /* var */_modeBtn: GButton;

        /* internal */ /* var */_campSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_campPicName: string;

        /* internal */ /* var */_campBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_teamMarkBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_linkText: Object /* flash.text.TextField */;

        /* internal */ /* var */_operMenuSprite: Object /* flash.display.Sprite */;

        /* internal */ /* var */_vip: GButton;

        /* internal */ /* var */_vipHelpBtn: GImageButton;

        /* internal */ /* var */_energy: int;

        /* internal */ /* var */_sMiniPlayer: SPublicMiniPlayer;

        /* internal */ /* var */_playerMiniInfo: PlayerMiniInfo;

        /* internal */ /* var */_lifeDrugBagItem: DrugBagItem;

        /* internal */ /* var */_manaDrugBagItem: DrugBagItem;

        /* internal */ /* var */_worldExBuff: WorldExBuff;

        /* internal */ /* var */_energyBar: BaseProgressBar;

        /* internal */ /* var */_energyTiptxt: GTextFiled;

        /* internal */ /* var */_flyBtn: GLoadedButton;

        /* internal */ /* var */_flyEndBtn: GLoadedButton;

        /* internal */ /* var */_minBtn: GButton;

        /* internal */ /* var */_totalLoadReward: TotalLoadRewardLogo;

        /* internal */ /* var */_isAlertEnergyMax: Boolean=false;

        /* internal */ /* var */_isInitEnergyBar: Boolean=false;

        /* internal */ /* var */_lockBtn: GButton;
    }
